<input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>">

<?php $num = 0;$num2 = 0; ?>

<?php
   $jobid = JRequest::getInt('jobid', 0); 
   $dir = JRequest::getString('dir', 'all');
   
   foreach($_['resumes'] as $resume):
   $viewURL = $_['viewURL'].$resume->id.'&name='.JFilterOutput::stringURLUnicodeSlug($resume->name).'&t='.$_['searchtoken'];
   $relative_modified_date = $resume->date_added; 
   // the older the file, the brighter the shade of grey; days*14
   $relative_date_color = round((time()-JFactory::getDate($relative_modified_date)->toUnix())/60/60/24*14);
   if($relative_date_color>200) $relative_date_color = 200;

   $match_degree_color = $resume->match_degree > 79 ? 'green' : 
                        ($resume->match_degree > 49 ? 'blue' : 
                         ($resume->match_degree > 0 ? 'orange' : 'gray')
                        );
   $interview_progress_color = $resume->online_interview_completion > 90 ? 'blue' : 
                               ($resume->online_interview_completion > 0 ? 'grayblue' : 'gray');
   $online_interview_requirements = json_decode($resume->online_interview_requirements);
   $issetup = 0;

   if (!empty($online_interview_requirements)) {
      if (isset($online_interview_requirements->onlineinterview) && $online_interview_requirements->onlineinterview && ( (isset($online_interview_requirements->onlinetest) && $online_interview_requirements->onlinetest) || (isset($online_interview_requirements->persontest) && $online_interview_requirements->persontest) )) {
         $issetup = 1;
      }
   } else {
      $issetup = 0;
   }

?>

   <tr <?php echo ($num % 2 == 0) ? '' : 'bgcolor="#f5f7f8"'; $num++; ?> class="control_trselect <?php echo $resume->is_new ? 'bold': ''; echo !empty($_['showdetail']) ? ' tr_hovercolor' : ''; ?>" 
      data-id="<?php echo $resume->id; ?>"
      data-source="<?php echo $resume->source; ?>"
      data-name="<?php echo $resume->name;?>"
      data-href="<?php echo $viewURL;?>"
      data-jobsystem="<?php echo $resume->jobsystem;?>"
      data-issetup="<?php echo $issetup;?>"
      data-trashed="<?php echo $resume->is_trashed;?>"
      data-saved="<?php echo $resume->is_saved;?>"
      data-type="<?php echo $dir;?>"
      data-mime="<?php echo 'application/octet-stream';?>"
      data-permissions='<?php echo $resume->permissions; ?>'>
      <td width="230" class="resumename svg resumeactions">
         <div style="<?php echo $dir == "trashed" ? 'padding:0 88px 0 20px;' : 'padding:0 88px 0 60px;'; ?>">
            <input type="checkbox" autocomplete="off" class="osp_input"/>

            <?php if($dir != "trashed"): ?>
               <a class="action share<?php echo ($resume->permissions == OCP\PERMISSION_READ) ? " unclick" : "" ; ?>" href="#" data-item="<?=$resume->id?>" data-animation="false" data-action="Share" title="<?php echo ($resume->permissions == OCP\PERMISSION_READ) ? "您没有权限分享该简历" : "分享" ; ?>"></a>
               <?php if($resume->is_saved):?>
               <a class="action unsave" href="#" data-item="<?=$resume->id?>" data-animation="false" data-action="Unsave" title="取消收藏"></a>
               <?php else:?>
               <a class="action save" href="#" data-item="<?=$resume->id?>" data-animation="false" data-action="Save" title="收藏"></a>
               <?php endif; ?>
            <?php endif; ?>

            <?php if($resume->permissions & OCP\PERMISSION_DELETE): ?>
            <?php if($dir == "trashed"): ?>
               <a class="action restore" href="#" data-item="<?=$resume->id?>" data-animation="false" data-action="Restore" title="恢复"></a>
               <a class="action permdelete" href="#" data-item="<?=$resume->id?>" data-animation="false" data-action="Permdelete" title="永久删除"></a>
            <?php endif; ?>
            <?php endif; ?>
            <a class="name" href="<?=$viewURL?>" target="_blank">
               <span class="nametext" style="min-width:50px; /*display:inline-block;*/"><?php echo htmlspecialchars($resume->name);?></span>
            </a>
            <span class="clearfix">
               <?php echo $resume->sex == 'F' ? "<span class='wresumepng'></span>": "<span class='mresumepng'></span>"; ?>
               <?php 
               $sources_sorted = array("upload","51job","zhilian","lagou","jiancai");
               $sources = explode(",", $resume->source);
               $sources = array_intersect($sources_sorted, $sources);
               if(count($sources)>0){
                  foreach($sources as $source){
                     echo "<span class='from_".$source." pull-right'></span>";
                  }
               }
               ?>
            </span>
            <span class="clicktoggle <?=(!empty($_['showdetail']) ? 'clicktoggle_up' : '')?>"></span>
         </div>
      </td>
      
      <td class="resumestatus" width="100">
         <span class="resume_status_select" style="cursor: default;">
         <em class="resume_status_text">
            <?php 
            if($resume->status_title === '--(未筛选)') {
               echo '<span class="normalgray">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--</span>';
            } else {
               echo $resume->status_title;
            }
            ?>
         </em>
         </span>
      </td>

      <td width="90" class="resumework"> 
            <?php echo empty($resume->workexp_summary)? ($resume->source!='upload' ? "应届毕业生": '') : $resume->workexp_summary;; ?>
      </td>

      <td width="60" class="resumedegree"> 
            <span class="degree_relative"><?php echo empty($resume->highest_education_degree_level) ? '' :$resume->highest_education_degree_level; ?><?=$resume->school_level&0x01 ? "<i class='from_985' ></i>" : ($resume->school_level&0x02 ? "<i class='from_211' ></i>" : "")?></span>
      </td>
      
      <td class="resumeposition" style="display: <?=(empty($jobid) ? '' : 'none')?>" width="320"> 
         <?php if(empty($resume->jobsystem)):?>
         <a class="jobposition" href="<?php echo  OC_Helper::linkToRoute('jobpos_setup').'?id='.$resume->jobid.'&job_title='.JFilterOutput::stringURLUnicodeSlug($resume->job_title); ?>">
            <?php echo $resume->job_title; ?>
         </a>
         <?php else:?>
            <?php echo $resume->job_title =='无职位' ? '--':$resume->job_title; ?>
         <?php endif;?>
      </td>

      <td width="90" class="resumematch" align="center">
         <?php
         $online_interview_progress = json_decode($resume->online_interview_progress);
         $title = ""; 
         $degree = "";
         if(isset($online_interview_progress->interview)) {
            $degree = "<span>" . $resume->match_degree . "%</span>";
            if($online_interview_progress->interview<=0){
               $title = "应聘者主动放弃";               
            }
         }else{
            $title = "应聘者尚未回应，暂无匹配信息"; 
            $degree = "<span class='normalgray'>--%</span>";
         }
         ?>
         <div class="match_degree_mask <?echo isset($online_interview_progress->interview) ? "matched click" : "nomatch"?>" title="<?=$title?>">
         <?php echo $degree; ?>
         <br/>
         <div class="match_degree">
            <div class="<?php echo $match_degree_color; ?>" style="width:<?php echo $resume->match_degree; ?>%;"></div>
         </div>
         </div>
      </td>
      
      <td width="100" class="resumetest" align="left">
         <?php
         $requirementsCount = 0;
         if (!empty($online_interview_requirements)) {
         ?>
         <div style="padding-left:15px;">
            <?php 
            if (isset($online_interview_requirements->onlinetest) && $online_interview_requirements->onlinetest): 
               $requirementsCount++;
            ?>
            <?php 
               $taken = isset($online_interview_progress->onlinetest) && $online_interview_progress->onlinetest; 
               $class = $taken ? ($resume->is_reviewed ? 'done' : '') : 'gray';
            ?>
            <a href="<?php echo $taken ? OC_Helper::linkToRoute("resume_reviewpaper")."?id=".$resume->id : "javascript:;"?>" class="penciltest" target="<?=($taken ? '_blank': '')?>">
               <i class="online_interview penceltest <?=$class?>" title="<?=($taken ? '': '未完成线上笔试')?>"></i>
            </a>
            <?php endif; ?>
            <?php 
            if (isset($online_interview_requirements->persontest) && $online_interview_requirements->persontest): 
               $requirementsCount++;
            ?>
            <?php 
               $taken = isset($online_interview_progress->persontest) && $online_interview_progress->persontest; 
            ?>
            <i class="online_interview persontest <?=($taken ? '' : 'gray')?>" title="<?=($taken ? '': '未完成性格评测')?>"></i>
            <?php endif; ?>
            <?php 
            if (isset($online_interview_requirements->video) && $online_interview_requirements->video): 
               $requirementsCount++;
            ?>
            <i class="online_interview videotest gray"></i>
            <?php endif; ?>
         </div>
         <?php
         }
         if ($requirementsCount == 0) {
            echo '<span title="未配置线上笔试,性格评测" class="normalgray" style="text-align:left; margin-left:20px;">--</span>';
         }
         ?>
      </td>
      
      <td width="120" align="center" class="date">
         <span class="modified" title="<?php echo JHtml::_('date',$resume->date_added, 'Y-m-d H:i:s'); ?>" data-placement="left">
            <?php echo JHtml::_('date',$resume->date_added, 'Y-m-d'); ?>
         </span>
      </td>
   </tr>
   <tr class="tdnoborder_bottom control_tr">
      <td class="resume_detailtd" colspan="8" width="100%">            
         <div class="relative">
            <div class="resumedetails" <?=(!empty($_['showdetail']) ? '' : 'style="display: none;"')?>>
               <?php 
               $resumeTags = (!empty($resume->tags)) ? explode(',', $resume->tags) : null;
               ?>
               <div class="clearfix" style="padding-top:10px;">
                  <?php
                  $educationInfo = array();
                  if (!empty($resume->highest_education_school_name)) {
                     $educationInfo[] = $resume->highest_education_school_name;
                  }
                  if (!empty($resume->highest_education_major_name)) {
                     $educationInfo[] = $resume->highest_education_major_name;
                  }
                  $educationInfoHtml = '';
                  if (!empty($educationInfo)) {
                     $educationInfoHtml = implode('&nbsp;&nbsp;|&nbsp;&nbsp;', $educationInfo);
                  }
                  
                  $workInfo = array();
                  if (!empty($resume->latest_workexp_company_name)) {
                     $workInfo[] = $resume->latest_workexp_company_name;
                  }
                  if (!empty($resume->latest_workexp_job_spec)) {
                     $workInfo[] = $resume->latest_workexp_job_spec;
                  }
                  if (!empty($resume->latest_workexp_job_title)) {
                     $workInfo[] = $resume->latest_workexp_job_title;
                  }
                  if (!empty($resume->latest_workexp_exp)) {
                     $workInfo[] = $resume->latest_workexp_exp;
                  }
                  $workInfoHtml = '';
                  if (!empty($workInfo)) {
                     $workInfoHtml = implode('&nbsp;&nbsp;|&nbsp;&nbsp;', $workInfo);
                  }
                  
                  $workexpInfo = array();
                  if (!empty($resume->workexpcount)) {
                     $workexpInfo[] = '共从事' . $resume->workexpcount . '份工作';
                     if($resume->workexpcount >= 2) {
                        $workexpInfo[] = '最长' . getTimeFromMonths($resume->maxworktime);
                        $workexpInfo[] = '最短' . getTimeFromMonths($resume->minworktime);
                     }
                  }
                  
                  $workexpInfoHtml = '';
                  if (!empty($workexpInfo)) {
                     if(count($workexpInfo) >= 2)
                        $workexpInfoHtml = implode('&nbsp;&nbsp;|&nbsp;&nbsp;', $workexpInfo);
                     else 
                        $workexpInfoHtml = array_shift($workexpInfo);
                  }
                  ?>
                  <div class="pull-left resumejob" style="margin-left:38px;"><b>院校专业：</b><?php echo $educationInfoHtml ? $educationInfoHtml : "---"; ?></div>
                  <div class="pull-left resumejob" style="margin-left:38px;"><b>最近工作：</b><?php echo $workInfoHtml ? $workInfoHtml : "---"; ?></div>
                  <div class="pull-left resumejob" style="margin-left:38px;"><?php echo $workexpInfoHtml; ?></div>
                  <?php if($resume->workexp_skills !="") {?>
                     <?php if(compact_strlen($resume->workexp_skills) <= 60) {?>
                        <br/><div class="pull-left resumejob" style="margin-left:38px;"><b>技能：</b><?php echo $resume->workexp_skills; ?></div>
                     <?php } else {?>
                  	   <br/><div class="pull-left resumejob" style="margin-left:38px;"><b>技能：</b><?php echo JString::substr($resume->workexp_skills, 60) . '...'; ?></div>
                     <?php }?>
                  <?php }?>
               </div>
               <div class="resume_hrtaget">
               <?php if(!empty($resumeTags)):?>
                  <b>标签：</b>
                  <?php 
                  $searchUrl = OC_Helper::linkToRoute('resumes_search') . '?dir=' . $dir;
                  foreach($resumeTags as $resumeTag) {
                     list($href, $selected) = PResumesHelper::getSearchItemHref($searchUrl, 'tag', rawurlencode($resumeTag));
                     echo "<span><a href=" . $href . ">" . $resumeTag . "</a></span>";
                  }
                  ?>
               <?php endif; ?>
               </div>
            </div>
            <!-- <div class="clicktoggle" title="点击查看详情" data-delay="1"></div> -->
         </div>
      </td>
   </tr>
<?php endforeach;?>
